import { Routes, Route } from 'react-router-dom';
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
import DashboardPage from './pages/DashboardPage';
import Layout from './components/Layout';
import ProtectedRoute from './components/ProtectedRoute'; // 引入
import KnowledgePointFormPage from './pages/KnowledgePointFormPage'; // 引入
import FeynmanRecordPage from './pages/FeynmanRecordPage'; // 引入费曼学习页面
import QuizPage from './pages/QuizPage'; // 引入答题页面
import RagSearchPage from './pages/RagSearchPage'; // 引入RAG搜索页面

function App() {
  return (
    <div>
      <h1>费曼学习法平台</h1>
      <Routes>
        <Route path='/' element={<Layout />}>
          {/* 公共路由 */}
          <Route path='login' element={<LoginPage />} />
          <Route path='register' element={<RegisterPage />} />
          
          {/* 受保护的路由 */}
          <Route element={<ProtectedRoute />}>
            <Route index element={<DashboardPage />} />
            <Route path="/kp/new" element={<KnowledgePointFormPage />} />
            <Route path="/kp/edit/:id" element={<KnowledgePointFormPage />} />
            <Route path="/feynman-record/:id" element={<FeynmanRecordPage />} />
            <Route path="/quiz/:id" element={<QuizPage />} />
            <Route path="/rag-search" element={<RagSearchPage />} />
            {/* 未来其他的受保护页面也可以放在这里 */}
          </Route>
        </Route>
      </Routes>
    </div>
  );
}
export default App;